package com.ats.web.managed;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;

import com.ats.ereg.model.entities.TstCourses;
import com.ats.ereg.model.service.TstCoursesService;

@ManagedBean(name = "tstCoursesMB")
@ViewScoped
public class TstCoursesMB {

	private List<TstCourses> entitiesList;
	private TstCourses selectedEntity = new TstCourses();

	@ManagedProperty(value = "#{TstCoursesService}")
	private TstCoursesService service;

	@PostConstruct
	private void init(){
		setEntitiesList( getService().getAllItems());
	}
	
	public TstCourses getSelectedEntity() {
		if (selectedEntity == null)
			selectedEntity = new TstCourses();
		return selectedEntity;
	}
	
	/**
	 * @param selectedEntity the selectedEntity to set
	 */
	public void setSelectedEntity(TstCourses selectedEntity) {
		this.selectedEntity = selectedEntity;
	}	

	/**
	 * @return the entitiesList
	 */
	public List<TstCourses> getEntitiesList() {
	    if (entitiesList == null) {
	        entitiesList = getService().getAllItems();
	    }
	    
		return entitiesList;
	}

	/**
	 * @param entitiesList the entitiesList to set
	 */
	public void setEntitiesList(List<TstCourses> entitiesList) {
		this.entitiesList = entitiesList;
	}

	/**
	 * @return the service
	 */
	public TstCoursesService getService() {
		return service;
	}

	/**
	 * @param service the service to set
	 */
	public void setService(TstCoursesService service) {
		this.service = service;
	}



}
